//
//  mainTabBarViewController.m
//  Books
//
//  Created by tao故乡的云 on 2017/3/8.
//  Copyright © 2017年 故乡的云. All rights reserved.
//

#import "mainTabBarViewController.h"
#import "BookCityTableViewController.h"
#import "BookrackTableViewController.h"
#import "MineTableViewController.h"
#import "TLChengYuViewController.h"
#import "TLNavigationController.h"
#import "TLReadView.h"

@interface mainTabBarViewController ()

@end

@implementation mainTabBarViewController

+ (void)initialize {
    // 设置tabbarItem title字体属性
    // title的富文本属性
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    // 默认状态颜色
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    [[UITabBarItem appearance] setTitleTextAttributes:attrs forState:UIControlStateNormal];
    // 选中状态颜色
    NSMutableDictionary *attrs2 = [NSMutableDictionary dictionary];
    attrs2[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    attrs2[NSForegroundColorAttributeName] = [UIColor orangeColor];
    [[UITabBarItem appearance] setTitleTextAttributes:attrs2 forState:UIControlStateSelected];
    

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    // add sub controllers
    [self addSubControllers];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// add sub controllers
- (void)addSubControllers {
    // 童心
//    BookCityTableViewController *bookCityVC = [[BookCityTableViewController alloc] init];
//    [self addSubController:bookCityVC tabBarItemWithImage:@"tabbar_home" selectedImage:@"tabbar_home_highlighted" title:@"童心"];
    
   // 汤鸡
//    BookrackTableViewController *bookrackVC = [[BookrackTableViewController alloc] init];
//    [self addSubController:bookrackVC tabBarItemWithImage:@"tabbar_discover" selectedImage:@"tabbar_discover_highlighted" title:@"汤鸡"];

    // 成语
    TLChengYuViewController *chengyuVC = [[TLChengYuViewController alloc] init];
    [self addSubController:chengyuVC tabBarItemWithImage:@"tabbar_home" selectedImage:@"tabbar_home_highlighted" title:@"成语"];

    
    // 我的
    MineTableViewController *mineVC = [[MineTableViewController alloc] init];
    [self addSubController:mineVC tabBarItemWithImage:@"tabbar_profile" selectedImage:@"tabbar_profile_highlighted" title:@"我"];
    
}

- (void)addSubController:(UIViewController *)VC tabBarItemWithImage:(NSString *)image selectedImage:(NSString *)selectedImage title:(NSString *)title {

    VC.title = title;
    VC.tabBarItem.image = [UIImage imageNamed:image];
    VC.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    TLNavigationController *nav = [[TLNavigationController alloc] initWithRootViewController:VC];
    [self addChildViewController:nav];
}


@end
